package com.cyy.common.config.jackson;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.lang.Nullable;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * LocalDate 转换器
 */
@Configuration
public class MyLocalDateConverter implements Converter<String, LocalDate>, BaseTimeDeserializer {

    @Override
    public LocalDate convert(@Nullable String source) {
        // 日期格式转转换
        LocalDateTime localDateTime = this.getLocalDateTimeBySource(source);
        return localDateTime == null ? null : localDateTime.toLocalDate();
    }

}
